package com.zte.sys.area.control;

import com.zte.sys.area.model.AreaCondition;
import com.zte.sys.area.model.SysCity;
import com.zte.sys.area.service.IAreaService;
import com.zte.util.OperatorLog;
import com.zte.util.PageModel;
import com.zte.util.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class AreaAction {

    @Autowired
    private IAreaService areaService;

    //分页查询
    @RequestMapping("/area/pageArea")
    @ResponseBody
    @OperatorLog(operate="区域分页条件查询", module="区域管理")
    public ResultMessage pageModule(AreaCondition conn, PageModel<SysCity> pageModel) {
        PageModel<SysCity> cities = areaService.queryCityPageByCondition(conn,pageModel);
        ResultMessage rm = new ResultMessage();
        if (cities != null) {
            rm.setFlag(true);
            rm.setStatus(200);
            rm.setMsg("查询成功！");
            rm.setData(cities);
        } else {
            rm.setFlag(false);
            rm.setStatus(500);
            rm.setMsg("查询失败！");
        }
        return rm;
    }


    @RequestMapping("/area/listArea")
    @ResponseBody
    public ResultMessage queryCityListByCondition(AreaCondition conn){
        List<SysCity> cities = areaService.queryCityListByCondition(conn);
        ResultMessage rm = new ResultMessage();
        if (cities != null) {
            rm.setFlag(true);
            rm.setStatus(200);
            rm.setMsg("查询成功！");
            rm.setData(cities);
        } else {
            rm.setFlag(false);
            rm.setStatus(500);
            rm.setMsg("查询失败！");
        }
        return rm;
    }
}
